//
// Source code recreated from ConfigVo .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.ht.modules.system.online.cgform.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Iterator;
import java.util.List;
import jakarta.annotation.Resource;
import com.ht.modules.system.online.cgform.entity.OnlCgformIndex;
import com.ht.modules.system.online.cgform.mapper.OnlCgformHeadMapper;
import com.ht.modules.system.online.cgform.mapper.OnlCgformIndexMapper;
import com.ht.modules.system.online.cgform.service.IOnlCgformIndexService;
import org.springframework.stereotype.Service;

@Service
public class OnlCgformIndexServiceImpl extends ServiceImpl<OnlCgformIndexMapper, OnlCgformIndex> implements IOnlCgformIndexService {
    @Resource
    private OnlCgformHeadMapper onlCgformHeadMapper;

    public OnlCgformIndexServiceImpl() {
    }

    public void createIndex(String code, String databaseType, String tbname) {
        LambdaQueryWrapper<OnlCgformIndex> query = new LambdaQueryWrapper();
        query.eq(OnlCgformIndex::getCgformHeadId, code);
        List<OnlCgformIndex> indexes = this.list(query);
        String sql;
        if (indexes != null && indexes.size() > 0) {
            for(Iterator var6 = indexes.iterator(); var6.hasNext(); this.onlCgformHeadMapper.executeDDL(sql)) {
                OnlCgformIndex cgform = (OnlCgformIndex)var6.next();
                sql = "";
                String indexName = cgform.getIndexName();
                String indexField = cgform.getIndexField();
                String indexType = "normal".equals(cgform.getIndexType()) ? " index " : cgform.getIndexType() + " index ";
                byte var13 = -1;
                switch(databaseType.hashCode()) {
                case -1955532418:
                    if (databaseType.equals("ORACLE")) {
                        var13 = 1;
                    }
                    break;
                case -1620389036:
                    if (databaseType.equals("POSTGRESQL")) {
                        var13 = 3;
                    }
                    break;
                case 73844866:
                    if (databaseType.equals("MYSQL")) {
                        var13 = 0;
                    }
                    break;
                case 912124529:
                    if (databaseType.equals("SQLSERVER")) {
                        var13 = 2;
                    }
                }

                switch(var13) {
                case 0:
                    sql = "create " + indexType + indexName + " on " + tbname + "(" + indexField + ")";
                    break;
                case 1:
                    sql = "create " + indexType + indexName + " on " + tbname + "(" + indexField + ")";
                    break;
                case 2:
                    sql = "create " + indexType + indexName + " on " + tbname + "(" + indexField + ")";
                    break;
                case 3:
                    sql = "create " + indexType + indexName + " on " + tbname + "(" + indexField + ")";
                    break;
                default:
                    sql = "create " + indexType + indexName + " on " + tbname + "(" + indexField + ")";
                }
            }
        }

    }
}
